package com.isaac.actm.domain.util;

import javax.persistence.EntityManagerFactory;

import org.hibernate.SessionFactory;
import org.hibernate.stat.Statistics;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.test.util.ReflectionTestUtils;

public class JpaUtil {

    public JpaTemplate jpaTemplate;

    public Statistics getJpaStatistics(){
	    EntityManagerFactory emf = jpaTemplate.getEntityManagerFactory();
	    SessionFactory sf = (SessionFactory) ReflectionTestUtils.invokeGetterMethod(emf, "getSessionFactory");
	    return sf.getStatistics();
	}

	public JpaTemplate getJpaTemplate() {
        return jpaTemplate;
    }

    public void setJpaTemplate(JpaTemplate jpaTemplate) {
        this.jpaTemplate = jpaTemplate;
    }
    
}